]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
screenshot-ui: Add a screencast in progress property
authorIvan Molodetskikh <yalterz@gmail.com>
Sat, 27 Nov 2021 07:41:24 +0000 (10:41 +0300)
committerMarge Bot <marge-bot@gnome.org>
Sat, 29 Jan 2022 14:43:49 +0000 (14:43 +0000)
The screen recording menu entry will use this to check if a screencast
is currently active and to stop the screencast.

Use a GObject property so we can bind to notify; specifically we'll bind
the visibility of a screencast area indicator.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2103>

js/ui/screenshot.js

index ce6ff26a2e101d11016447bb2c8dc7874a869ab4..7417376239d01de3edcde727ee19d8c1d3bbb598 100644 (file)
@@ -995,8 +995,16 @@ class UIWindowSelector extends St.Widget {
     }
 });
 
-var ScreenshotUI = GObject.registerClass(
-class ScreenshotUI extends St.Widget {
+var ScreenshotUI = GObject.registerClass({
+    Properties: {
+        'screencast-in-progress': GObject.ParamSpec.boolean(
+            'screencast-in-progress',
+            'screencast-in-progress',
+            'screencast-in-progress',
+            GObject.ParamFlags.READABLE,
+            false),
+    },
+}, class ScreenshotUI extends St.Widget {
     _init() {
         super._init({
             name: 'screenshot-ui',
@@ -1010,6 +1018,8 @@ class ScreenshotUI extends St.Widget {
             reactive: true,
         });
 
+        this._screencastInProgress = false;
+
         this._lockdownSettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.lockdown' });
 
         // The full-screen screenshot has a separate container so that we can
@@ -1820,6 +1830,30 @@ class ScreenshotUI extends St.Widget {
         }
     }
 
+    stopScreencast() {
+        if (!this._screencastInProgress)
+            return;
+
+        // Set this before calling the method as the screen recording indicator
+        // will check it before the success callback fires.
+        this._setScreencastInProgress(false);
+    }
+
+    get screencast_in_progress() {
+        if (!('_screencastInProgress' in this))
+            return false;
+
+        return this._screencastInProgress;
+    }
+
+    _setScreencastInProgress(inProgress) {
+        if (this._screencastInProgress === inProgress)
+            return;
+
+        this._screencastInProgress = inProgress;
+        this.notify('screencast-in-progress');
+    }
+
     vfunc_key_press_event(event) {
         const symbol = event.keyval;
         if (symbol === Clutter.KEY_Return || symbol === Clutter.KEY_space ||